package com.jiutong.meipengdai.ui.activitys;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiutong.meipengdai.R;
import com.jiutong.meipengdai.base.BaseActivity;
import com.jiutong.meipengdai.entity.BaseRespond;
import com.jiutong.meipengdai.http.model.interfaces.BankListBiz;
import com.jiutong.meipengdai.http.present.BankListPresent;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by suxi on 2017/6/20.
 */

public class BankCardUnbindActivity extends BaseActivity implements BankListBiz{
    @Bind(R.id.rl_back)
    RelativeLayout rlBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_bank_card)
    TextView tvBankCard;
    @Bind(R.id.tv_bank_name)
    TextView tvBankName;
    @Bind(R.id.et_phonenum)
    EditText etPhonenum;
    @Bind(R.id.btn_unbind)
    Button btnUnbind;
    private String bankNum;
    private String bankId;
    private BankListPresent bankListPresent;
    private String bankName;

    @Override
    public int getLayoutResouceId() {
        return R.layout.activity_bankcare_unbind;
    }

    @Override
    protected void initDate(Bundle savedInstanceState) {
        super.initDate(savedInstanceState);
        bankNum = getIntent().getExtras().getString("bankNum");
        bankId = getIntent().getExtras().getString("bankId");
        bankName = getIntent().getExtras().getString("bankName");
        bankListPresent = new BankListPresent(mContext, this);
    }

    @Override
    protected void initView() {
        super.initView();
        ButterKnife.bind(this);
        tvTitle.setText("解绑银行卡");
        tvBankCard.setText(bankNum);
        tvBankName.setText(bankName);
    }

    @OnClick({R.id.rl_back, R.id.btn_unbind})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
            case R.id.btn_unbind:
                if(TextUtils.isEmpty(getPhoneNo())){
                    toastShortShow("请输入预留手机号码");
                    break;
                }
//                bankListPresent.delBannkInfo();
                break;
        }
    }

    @Override
    public String getBankNumber() {
        return null;
    }

    @Override
    public String getPhoneNo() {
        return etPhonenum.getText().toString().trim();
    }

    @Override
    public String getBankId() {
        return bankId;
    }

    @Override
    public void onSuccess(Object object) {
        BaseRespond respond = (BaseRespond) object;
        toastShortShow(respond.getResDesc());
        if("200".equals(respond.getResCode())){
            openActivity(BankCardListActivity.class);
        }
    }

    @Override
    public void onError(Throwable e) {

    }
}
